package fr.cephb.operonj.core.db.database;

import com.sleepycat.bind.tuple.TupleBinding;
import com.sleepycat.je.DatabaseConfig;
import com.sleepycat.je.DatabaseException;
import com.sleepycat.je.Environment;
import com.sleepycat.je.Transaction;

import fr.cephb.operonj.core.bio.ChromInfo;
import fr.cephb.operonj.core.db.binding.BuildChromBinding;
import fr.cephb.operonj.core.db.binding.ChromInfoBinding;
import fr.cephb.operonj.core.db.comparator.BuildChromComparator;
import fr.cephb.operonj.core.db.key.BuildChrom;
import fr.cephb.operonj.core.je.PrimaryDB;

public class ChromDB
	extends PrimaryDB<BuildChrom,ChromInfo>
	{
	private BuildChromBinding keyBinding=new BuildChromBinding();
	private ChromInfoBinding valueBinding= new ChromInfoBinding();
	
	
	protected static DatabaseConfig setCfgSorter(DatabaseConfig cfg)
		{
		cfg.setBtreeComparator(BuildChromComparator.class);
		return cfg;
		}
	
	public ChromDB(
			Environment env,
			Transaction txn,
			String databaseName,
			DatabaseConfig dbConfig
			) throws DatabaseException
		{
		super(env, txn, databaseName, setCfgSorter(defaultDbCfg(env,dbConfig)));
		}

	private static final String DEFAULT_NAME="buildChrom2chromInfo";
	
	
	
	@Override
	public String getDefaultName()
		{
		return DEFAULT_NAME;
		}

	@Override
	public TupleBinding<BuildChrom> getKeyBinding()
		{
		return keyBinding;
		}
	
	@Override
	public TupleBinding<ChromInfo> getValueBinding()
		{
		return valueBinding;
		}
	}
